#include "widget.h"
#include "ui_widget.h"

#include <QDebug>
#include <QTimerEvent>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    timerId = this->startTimer(1000);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::timerEvent(QTimerEvent *event)
{
    if (event->timerId() != this->timerId)
    {
        // 不是我们的定时器
        return;
    }

    int value = ui->lcdNumber->intValue();
    if (value <= 0)
    {
        this->killTimer(this->timerId);
        return;
    }

    value -= 1;
    ui->lcdNumber->display(value);
}

